package com.ziqi.hututubackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ziqi.hututubackend.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.ziqi.hututubackend.model.VO.PictureVO;
import com.ziqi.hututubackend.model.dto.picture.*;
import com.ziqi.hututubackend.model.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ziqi.hututubackend.model.entity.User;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author wang
* @description 针对表【picture(图片)】的数据库操作Service
* @createDate 2025-01-11 23:39:47
*/
public interface PictureService extends IService<Picture> {


    /**
     * 上传图片方法
     * @param inputSource  url或本地文件
     * @param pictureUploadRequest  上传请求
     * @param loginUser 登录用户
     * @return
     */
    PictureVO uploadPicture(Object inputSource, PictureUploadRequest pictureUploadRequest, User loginUser);

    /**
     * 查询图片请求
     * @param pictureQueryRequest
     * @return
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);


    /**
     *  分页获取图片封装类
     * @param picturePage
     * @param request
     * @return
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);


    /**
     * 获取单个图片封装方法
     * @param picture 原始图片对象
     * @param request 请求
     * @return
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);


    /**
     * 图片数据校验方法（更新和修改图片时判断
     * @param picture
     */
    void vaildPicture(Picture picture);

    /**
     * 图片审核方法
     * @param pictureReviewRequest 审核参数
     * @param loginUser 当前登录用户
     */
    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * 填充审核参数
     * @param picture
     * @param loginUser
     */
    void fillReviewParams(Picture picture, User loginUser);

    /**
     * 批量抓取图片方法（从bing）
     * @param pictureUploadByBatchRequest  自定义的请求体
     * @param loginUser 登录用户（判读权限）
     * @return 抓取成功的图片数
     */
    Integer uploadPictureByBatch(PictureUploadByBatchRequest pictureUploadByBatchRequest, User loginUser);

    /**
     * 编辑图片
     * @param pictureEditRequest
     * @param loginUser
     */
    void editPicture(PictureEditRequest pictureEditRequest, User loginUser);

    /**
     * 删除图片（逻辑删除）
     * @param pictureId
     * @param loginUser
     */
    void deletePicture(long pictureId, User loginUser);

    /**
     * 删除cos对象存储中的图片文件
     * @param oldPicture
     */
    void clearPictureFile(Picture oldPicture);

    /**
     * 检查图片操作权限
     * @param loginUser  登录用户
     * @param picture 图片
     */
    void checkPictureAuth(User loginUser, Picture picture);

    /**
     * 根据图片的主色调搜索图片
     * @param spaceId 空间id
     * @param picColor 主色调
     * @param loginUser 登录用户
     * @return
     */
    List<PictureVO> searchPictureByColor(Long spaceId, String picColor, User loginUser);

    /**
     * 批量修改图片信息
     * @param pictureEditByBatchRequest 接受修改内容
     * @param loginUser 登录用户
     */
    void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, User loginUser);

    /**
     * 创建扩图任务
     * @param createPictureOutPaintingTaskRequest
     * @param loginUser
     * @return
     */
    CreateOutPaintingTaskResponse createPictureOutPaintingTask(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser);

}
